﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ArbolandiaBL
{
    internal class UIBanner : UIBannerBase
    {
        public override List<Picture> GetBanner(BannerType type)
        {
            List<Picture> res = new List<Picture>();
            try
            {
                string hosturl = _db.Parameters.Where(w => w.pkcode == "hostimages").FirstOrDefault<Parameters>().value;


                var query = from b in _db.Banners
                            join p in _db.Picture on b.PictureGuidId equals p.GuidId
                            where b.Position == (short)type
                            select p;
                foreach (var item in query)
                {
                    item.Url = item.Url.Replace("hostimages", hosturl);
                }
                res = query.Count() > 0 ? query.ToList() : new List<Picture>();
            }
            catch (Exception)
            {
            }
            return res;
        }
    }
}
